<h1>Debug API</h1>
<p>Not a computer programmer? Don't know what an API is? You're most likely lost. <a href="#/">Get me out of here!</a></p>
<p>Here you can play around with API calls to the swarmsim server at {{env.saveServerUrl}}. (Unlike the other debug page, this one's visible in production because you can't cheat with it. It is not a bug.) Have fun!</p>

<p>TODO: document available api calls. Until then,
<a target="_blank" href="http://github.com/swarmsim/swarm-server-sails/tree/master/config/routes.js">use the source</a>.
<a target="_blank" href="http://github.com/swarmsim/swarm-server-sails/tree/master/config/policies.js">This one, too</a>. It's mostly REST-style URLs, except for the AuthController and MiscController stuff.
</p>

<p ng-if="loginApi.user.id">Logged in as: <code>{{loginApi.user|json}}</code>. <a href="javascript:" ng-click="loginApi.logout()">Logout</a></p>
<p ng-if="!loginApi.user.id">Not logged in.</p>

<hr>
<h4>Make an API call</h4>
<p><code>window.submitApiCall()</code> works too, but only from this page.</p>
<form ng-submit="testApiCall()">
  <div class="form-group">
    <label>url</label>
    <input class="form-control" type="text" placeholder="/whoami" ng-model="form.url">
    <div><a ng-href="{{env.saveServerUrl}}{{form.url}}" target="_blank">{{env.saveServerUrl}}{{form.url}}</a></div>
  </div>
  <div class="form-group">
    <label>headers</label>
    <textarea class="form-control" placeholder="{'content-type': 'application/json', ...}" ng-model="form.headers"></textarea>
  </div>
  <div class="form-group">
    <label>body</label>
    <textarea class="form-control" placeholder="{foo='bar', baz='quux', ...}" ng-model="form.data"></textarea>
  </div>
  <button class="btn btn-default" ng-class="{disabled:calling}" ng-click="submitApiCall('get')">HTTP GET</button>
  <button class="btn btn-default" ng-class="{disabled:calling}" ng-click="submitApiCall('post')">HTTP POST</button>
</form>

<div id="testApiCallResults">
</div>
